package utils

import java.sql.{Connection, DriverManager}

object DBUtil {

  val url = "jdbc:mysql://192.168.3.248:3306/test?useUnicode=true&characterEncoding=utf8"
  val username = "iplastest"
  val password = "123456"
  classOf[com.mysql.jdbc.Driver]

  def getConnection():Connection = {
    DriverManager.getConnection(url,username,password)
  }

  def closeConnection(connection: Connection): Unit = {
    try{
      if(!connection.isClosed() || connection != null){
        connection.close();
      }
    }catch {
      case ex: Exception => {
        ex.printStackTrace()
      }
    }

  }


}
